﻿package mortal.game.view.combinedServer.combinedSerDayRe1000
{
    import Message.Game.*;
    import com.gengine.core.frame.*;
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.resource.*;
    import mortal.game.utils.*;
    import mortal.game.view.combinedServer.data.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class CombinedSerDayRe1000Module extends BaseWindow
    {
        protected var _bBg2:ScaleBitmap;
        protected var _rankTBg:ScaleBitmap;
        protected var _rankTName:GTextFiled;
        protected var _rankGold:GTextFiled;
        protected var ui_3:GImageBitmap;
        protected var _list2:GTileList;
        protected var _bBg1:ScaleBitmap;
        protected var _list1:GTileList;
        protected var _reNumDes:GTextFiled;
        protected var _reNum:GTextFiled;
        protected var _yuanbo:GBitmap;
        protected var _reBtn:GLoadingButton;
        protected var _day:BitmapNumberText;
        protected var _hour:BitmapNumberText;
        protected var _min:BitmapNumberText;
        protected var _sec:BitmapNumberText;
        protected var _resTimesTxt:GTextFiled;
        protected var _rankTitle:GImageBitmap;
        private var _secT:SecTimer;
        private static var _instance:CombinedSerDayRe1000Module;

        public function CombinedSerDayRe1000Module(param1:ILayer = null)
        {
            super(param1);
            setSize(900, 592);
            this.title = "合服逆袭返现";
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bBg2 = UIFactory.bg(659, 223, 240, 372, this, ImagesConst.PanelBg);
            this._rankTBg = UIFactory.bg(659, 288, 242, 23, this, ImagesConst.RegionTitleBg);
            this._rankTName = UIFactory.gTextField("名字", 732, 289, 100, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._rankGold = UIFactory.gTextField("今日充值钻石", 805, 289, 100, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this.ui_3 = UIFactory.gImageBitmap(ImagesConst.CombinedSerRe1000TopBg, 7, 37, this);
            this._list2 = UIFactory.tileList(661, 319, 240, 250, this);
            this._list2.direction = GBoxDirection.VERTICAL;
            this._list2.verticalGap = 0;
            this._list2.horizontalGap = 2;
            this._list2.rowHeight = 25;
            this._list2.columnWidth = 225;
            this._list2.columnCount = 1;
            this._list2.rowCount = 10;
            this._list2.width = 240;
            this._list2.setStyle("cellRenderer", CombinedSerDayRe1000Cell2);
            this._bBg1 = UIFactory.bg(5, 222, 655, 374, this, ImagesConst.PanelBg);
            this._list1 = UIFactory.tileList(10, 226, 645, 360, this);
            this._list1.direction = GBoxDirection.VERTICAL;
            this._list1.verticalGap = 0;
            this._list1.horizontalGap = 0;
            this._list1.rowHeight = 180;
            this._list1.columnWidth = 126;
            this._list1.columnCount = 5;
            this._list1.rowCount = 2;
            this._list1.width = 645;
            this._list1.setStyle("cellRenderer", CombinedSerDayRe1000Cell);
            this._reNumDes = UIFactory.gTextField("累计充值：", 532, 153, 100, 20, this, GlobalStyle.textFormatPutong.setColor(16777215).setSize(13));
            this._reNum = UIFactory.gTextField("12346", 600, 153, 100, 20, this, GlobalStyle.textFormatPutong.setColor(16777215).setSize(13));
            this._yuanbo = UIFactory.gBitmap(ImagesConst.Yuanbao, 689, 157, this);
            this._reBtn = UIFactory.gLoadingButton(ImagesConst.investmentRechargeBtn_upSkin, 743, 163, 141, 43, this);
            this._reBtn.label = "";
            this._day = UIFactory.bitmapNumberText(475, 185, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._day.text = "00";
            this._hour = UIFactory.bitmapNumberText(528, 185, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._hour.text = "00";
            this._min = UIFactory.bitmapNumberText(600, 185, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._min.text = "00";
            this._sec = UIFactory.bitmapNumberText(674, 185, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._sec.text = "00";
            this._resTimesTxt = UIFactory.gTextField("2/20", 428, 149, 66, 25, this, GlobalStyle.textFormatLv.setSize(19).center());
            this._rankTitle = UIFactory.gImageBitmap(ImagesConst.CombinedSerRe1000RankTitle, 650, 206, this);
            this.updateRecharge();
            this.updateRank();
            Dispatcher.dispatchEvent(new DataEvent(CombinedSerEvent.CombinedSerReqRankInfo));
            this._reBtn.configEventListener(MouseEvent.CLICK, this.onGoToRechargeHd);
            this._secT = new SecTimer(1);
            this._secT.addListener(TimerType.ENTERFRAME, this.timeCk);
            this._secT.start();
            this.timeCk(null);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._secT.stop();
            this._secT.dispose(param1);
            this._secT = null;
            this._bBg2 = null;
            this._rankTBg = null;
            this._rankTName = null;
            this._rankGold = null;
            this.ui_3 = null;
            this._list2 = null;
            this._bBg1 = null;
            this._list1 = null;
            this._reNumDes = null;
            this._reNum = null;
            this._yuanbo = null;
            this._reBtn = null;
            this._day = null;
            this._hour = null;
            this._min = null;
            this._sec = null;
            this._resTimesTxt = null;
            this._rankTitle = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function updateTopInfo() : void
        {
            var _loc_1:* = Cache.instance.combinedSer.recharge1000Info;
            if (_loc_1)
            {
                this._reNum.text = "" + _loc_1.recharge;
                this._resTimesTxt.text = "" + _loc_1.getTimes + "/" + CombinedSerDayRe1000Util.totalNum;
            }
            else
            {
                this._reNum.text = "" + Cache.instance.rebate.rechargeSum;
                this._resTimesTxt.text = "0" + "/" + CombinedSerDayRe1000Util.totalNum;
            }
            return;
        }// end function

        public function updateRecharge() : void
        {
            this.updateTopInfo();
            var _loc_1:* = this.getArr();
            var _loc_2:* = new DataProvider(_loc_1);
            this._list1.dataProvider = _loc_2;
            var _loc_3:* = CombinedSerDayRe1000Util.getRwIndex();
            if (_loc_3 > -1)
            {
                this._list1.scrollToIndex(_loc_3);
            }
            this._list1.drawNow();
            return;
        }// end function

        private function getArr() : Array
        {
            var _loc_3:Object = null;
            var _loc_1:Array = [];
            var _loc_2:int = 0;
            while (_loc_2 < 20)
            {
                
                _loc_3 = {};
                _loc_3.index = _loc_2;
                _loc_1.push(_loc_3);
                _loc_2++;
            }
            return _loc_1;
        }// end function

        public function updateRank() : void
        {
            var _loc_1:* = Cache.instance.combinedSer.rankList;
            var _loc_2:* = new DataProvider(_loc_1);
            this._list2.dataProvider = _loc_2;
            this._list2.drawNow();
            return;
        }// end function

        private function timeCk(param1:SecTimer) : void
        {
            var _loc_2:Array = null;
            var _loc_3:int = 0;
            _loc_2 = CombinedSerUtil.getDayCountDownTime();
            _loc_3 = _loc_2[5];
            this._day.text = "" + _loc_2[0];
            this._hour.text = "" + _loc_2[1];
            this._min.text = "" + _loc_2[2];
            this._sec.text = "" + _loc_2[3];
            if (_loc_3 > 0)
            {
                if (this._secT.running == false)
                {
                    this._secT.start();
                }
            }
            else
            {
                this._secT.stop();
            }
            return;
        }// end function

        private function onGoToRechargeHd(event:MouseEvent) : void
        {
            GameUtil.gotoRecharge(ModuleTypeConst.CombinedSerRecharge);
            return;
        }// end function

        public static function get instance() : CombinedSerDayRe1000Module
        {
            if (_instance == null)
            {
                _instance = new CombinedSerDayRe1000Module;
            }
            return _instance;
        }// end function

        public static function get isView() : Boolean
        {
            return _instance && !_instance.isHide;
        }// end function

    }
}
